using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.VisualStudio.Modeling.Validation;

namespace Evaluant.EussDSL
{
    [ValidationState(ValidationState.Enabled)]
    public partial class ReferenceNew
    {
        [ValidationMethod(ValidationCategories.Menu | ValidationCategories.Save)]
        private void NamePresent(ValidationContext context)
        {
            if (string.IsNullOrEmpty(name))
            {
                context.LogError("A reference to '" + entityChild + "' doesn't contain a 'name' value.", "024", this);
            }
        }

        [ValidationMethod(ValidationCategories.Menu | ValidationCategories.Save)]
        private void EntityChildPresent(ValidationContext context)
        {
            if (string.IsNullOrEmpty(entityChild))
            {
                context.LogError("A reference doesn't contain an 'entityChild' value.", "025", this);
            }
        }

        [ValidationMethod(ValidationCategories.Menu | ValidationCategories.Save)]
        private void ValidEntityChild(ValidationContext context)
        {
            if (!this.Entity.EussMapping.Elements.Exists(delegate(Entity en) { return en.type == entityChild; }))
            {
                context.LogError("An 'entityChild' value doesn't match an Entity 'type' in the mapping file.", "027", this);
            }
        }
    }
}
